home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 22 code / PCI Driver Sample / NCR_DriverProject / Src / PublishInitFailureMsg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-08  |  1.8 KB  |  54 lines  |  [TEXT/MPCC]

  1. /*                                    PublishInitFailureMsg.c                                */
  2. /*
  3.  * PublishInitFailureMsg.c
  4.  * Copyright © 1994-95 Apple Computer Inc. All rights reserved.
  5.  *
  6.  */
  7. /*    .___________________________________________________________________________________.
  8.       | This function stores a string into the Name Registry. It is called if an            |
  9.       | initialization function detects an error that would prevent the driver from        |
  10.       | loading. This may help debugging                                                     |
  11.     .___________________________________________________________________________________.
  12. */
  13.  
  14. #include "NCRDriverPrivate.h" 
  15.  
  16. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  17.  * Store an error value and text string into the registry.
  18.  */
  19. void
  20. PublishInitFailureMsg(                                    /* Initialization failure        */
  21.         OSErr                    errorStatus,            /* Writes this value and this    */
  22.         ConstStr255Param        messageText                /* text into the name registry    */
  23.     )
  24. {
  25.         OSErr                    status;
  26.         RegPropertyValueSize    size;
  27.         Str255                    work;
  28.  
  29.         Trace(PublishInitFailureMsg);
  30.         PStrCopy(work, (messageText == NULL) ? "\pUnknown reason" : messageText);
  31.         PStrCat(work, "\p: ");
  32.         AppendSigned(work, errorStatus);
  33.         work[++work[0]] = 0;                            /* C string terminator            */
  34.         /*
  35.          * Does the property currently exist - if so, exit so as we only want the first.
  36.          */
  37.         status = RegistryPropertyGetSize(        /* returns noErr if the property exists    */
  38.                     &GLOBAL.deviceEntry,
  39.                     kDriverFailurePropertyName,
  40.                     &size
  41.                 );
  42.         if (status != noErr) {
  43.             status = RegistryPropertyCreate(    /* Make a new property                    */
  44.                         &GLOBAL.deviceEntry,                    /* RegEntryID            */
  45.                         kDriverFailurePropertyName,                /* Property name        */
  46.                         (RegPropertyValue *) &work[1],            /* -> Property contents    */
  47.                         work[0]                                    /* Property size        */
  48.                     );
  49.             CheckStatus(status, "\pPublishInitFailureMsg - RegistryPropertyCreate");
  50.         }
  51. }
  52.  
  53.  
  54.